package com.kwok.rbac.application.exception;

import com.kwok.rbac.application.common.utils.R;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

@RestControllerAdvice
@Slf4j
public class GlobalExceptionHandler {

    //系统异常
    @ExceptionHandler(Exception.class)
    public R systemException(Exception e){
        log.debug("系统异常，请稍后再试~", e);
        return R.failure("系统异常，请稍后再试~");
    }

    //业务异常
    @ExceptionHandler(EmployeeException.class)
    public R employeeException(EmployeeException e){
        log.debug("业务异常，请仔细排查~", e);
        return R.failure(e.getCode(),e.getMsg());
    }

}
